// Copyright (c) 2025 Zhou Yiyan
// Dynamic World Generation Library is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
//          http://license.coscl.org.cn/MulanPSL2
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
// See the Mulan PSL v2 for more details.

// Package worldgen provides core types and interfaces for dynamic world generation.
package worldgen

const (
	// ChunkSize defines the dimensions of each chunk (32x32 tiles).
	ChunkSize = 32

	// DefaultDifficulty is the default difficulty coefficient.
	DefaultDifficulty = 0.5

	// DefaultSimilarity is the default similarity coefficient.
	DefaultSimilarity = 0.8
)

// transitionMatrix defines natural transition probabilities between tile types.
// Values represent how likely type A is to transition to type B (0.0 = impossible, 1.0 = certain).
var transitionMatrix = map[TileType]map[TileType]float64{
	TileTypeGrass: {
		TileTypeGrass:    0.8,
		TileTypeForest:   0.6,
		TileTypeWater:    0.3,
		TileTypeDesert:   0.2,
		TileTypeMountain: 0.1,
		TileTypeLava:     0.0,
		TileTypeEmpty:    0.0,
	},
	TileTypeForest: {
		TileTypeForest:   0.7,
		TileTypeGrass:    0.5,
		TileTypeMountain: 0.3,
		TileTypeWater:    0.1,
		TileTypeDesert:   0.0,
		TileTypeLava:     0.0,
		TileTypeEmpty:    0.0,
	},
	TileTypeWater: {
		TileTypeWater:    0.9,
		TileTypeGrass:    0.4,
		TileTypeForest:   0.2,
		TileTypeDesert:   0.1,
		TileTypeMountain: 0.0,
		TileTypeLava:     0.0, // Physically impossible
		TileTypeEmpty:    0.0,
	},
	// Add other types as needed
}

// String returns a human-readable representation of the TileType.
func (t TileType) String() string {
	switch t {
	case TileTypeEmpty:
		return "Empty"
	case TileTypeGrass:
		return "Grass"
	case TileTypeWater:
		return "Water"
	case TileTypeForest:
		return "Forest"
	case TileTypeMountain:
		return "Mountain"
	case TileTypeDesert:
		return "Desert"
	case TileTypeLava:
		return "Lava"
	default:
		return "Unknown"
	}
}
